import requests
from config import headers_web, url


class MajorDimensionMaterial:
    def __init__(self):
        self.headers_web = headers_web
        self.url = url

    @classmethod
    def post_major_dimension_page(cls, url: str, headers=headers_web, params=None, body=None):
        """
        @Summary: 获取专业资料列表接口
        @Description: 1.云课堂管理端-本科专业评估使用
        :param url: http://192.168.1.32:8080
        :param headers:{
                      "Content-Type":"application/json",
                      "X-Requested-With":"XMLHttpRequest",
                      "User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64)
                      AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36"
                    }
        :param params: {validCode: string #验证码（&signKey=123123）}
        :param body: {
                      "auditStatus": integer, #审核状态：0-未审核，1-审核通过，2-审核不通过
                      "collegeId": "string", #学院ID
                      "isTeachingQualityEvaluationAdmin": boolean, #是否校管理员 0：否；1：是
                      "isUpload": boolean, #是否上传：0-否，1-是
                      "majorName": "string", #专业名称
                      "operatorId": "string", #操作人ID
                      "page": integer, #当前页
                      "pageSize": integer, #每页数量
                      "sortName": "string", #排序字段 uploadTime:上传时间，不传或者其他值使用默认排序
                      "sortRule": "string" #排序规则：asc：升序；desc：降序
                    }
        :return:{
                "materialResourceList": [
                            {
                              "auditStatus": integer, #审核状态：0-未审核，1-审核通过，2-审核不通过
                              "collegeAdminIds": "string", #院管理员ids，多个用;拼接
                              "collegeAdminNames": "string", #院管理员姓名，多个用;拼接
                              "collegeAdminNos": "string", #院管理员工号，多个用;拼接
                              "collegeCode": "string", #学院编号
                              "collegeId": "string", #学院ID
                              "collegeName": "string", #学院名称
                              "id": "string", #专业资料ID
                              "isAllowAudit": boolean, #是否允许审核
                              "isAllowUpload": boolean, #是否允许上传
                              "isUpload": boolean, #是否上传 0-否，1-是
                              "majorCode": "string", #专业代码
                              "majorName": "string", #专业名称
                              "materialTypeResourceList": [{
                                  "isRequired": boolean, #是否必填
                                  "typeFileList": [{
                                      "fileDisplayName": "string", #文件显示名称
                                      "filePath": "string", #文件路径
                                      "fileRealName": "string", #文件存储名称
                                      "fileSize": integer, #文件大小
                                      "fileType": "string", #文件类型
                                      "innerUrl": "string", #内网ip
                                      "materialFileId": "string", #id
                                      "outerUrl": "string" #外网ip
                                    }],
                                  "typeId": "string", #类型ID
                                  "typeName": "string" #类型名称
                                }],
                              "operatorId": "string", #操作人Id
                              "operatorName": "string", #操作人姓名
                              "operatorNo": "string", #操作人工号
                              "startYear": "string", #开设年份
                              "uploadTime": "string" #上传时间
                            }],
              "page": integer, #当前页
              "pageSize": integer, #每页个数
              "total": integer #总页数
                        }
        """
        url_path = url + "/teachingqualityevaluationapi/v1/majordimensionmaterial/page"
        r = requests.post(url=url_path, params=params, headers=headers, json=body)
        return r

    @classmethod
    def get_major_dimension_flow(cls, url: str, headers=headers_web, params=None, params_path=None):
        """
        @Summary: 获取专业维度资料流程接口
        @Description: 1、云课堂管理端指标维度资料调用
        :param headers:{
                          "Content-Type":"application/json",
                          "X-Requested-With":"XMLHttpRequest",
                          "User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64)
                          AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36"
                        }
        :param url: http://192.168.1.32:8080
        :param params: {validCode: "string" #验证码（id={}&signKey=123123）}
        :param params_path: "string" # 专业资料ID
        :return: [{
                    "flowName": "string", #流程名称
                    "flowOperatorId": "string", #流程操作人ID
                    "flowOperatorName": "string", #流程操作人姓名
                    "flowOperatorNo": "string", #流程操作人工号
                    "flowOperatorTypeName": "string", #流程操作人类型名称
                    "id": "string" #专业资料ID
                  }]
        """
        url_path = url + f"/teachingqualityevaluationapi/v1/majordimensionmaterial/{params_path}/flow"
        r = requests.get(url=url_path, headers=headers, params=params)
        return r

